package com.huawei.secure.android.common.detect;

import android.content.Context;
import android.net.Proxy;
import android.os.Build.VERSION;
import android.text.TextUtils;
import android.util.Log;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;

public abstract class ProxyDetect {
    private static final String TAG = "ProxyDetect";

    public static boolean isWifiProxy(Context context) {
        int parseInt;
        CharSequence charSequence = null;
        if (VERSION.SDK_INT >= 14) {
            try {
                charSequence = System.getProperty("http.proxyHost");
                String property = System.getProperty("http.proxyPort");
                if (property == null) {
                    property = StartupResponse.CHANNELNO_QUERY_FAILURE;
                }
                parseInt = Integer.parseInt(property);
            } catch (SecurityException e) {
                Log.e(TAG, "message : " + e.getMessage());
                parseInt = 0;
            }
        } else {
            charSequence = Proxy.getHost(context);
            parseInt = Proxy.getPort(context);
        }
        if (TextUtils.isEmpty(charSequence) || r0 == -1) {
            return false;
        }
        return true;
    }
}
